import enum
import datetime

from sqlalchemy import Column, String, Integer, Enum, DateTime
from .base import Base


class Priority(enum.Enum):
    TP_LOW = 100
    TP_MIDDLE = 200
    TP_HIGH = 300


class TaskStatus(enum.Enum):
    TS_DONE = 0
    TS_CANCELED = 1
    TS_CREATED = 2


class CodeReviewTask(Base):
    __tablename__ = "task"

    id = Column(Integer, primary_key=True)
    submit_user_id = Column(Integer)
    process_user_id = Column(Integer)
    review_url = Column(String)
    priority = Column(Enum(Priority), default=Priority.TP_MIDDLE, index=True)
    status = Column(Enum(TaskStatus), default=TaskStatus.TS_CREATED, index=True)
    remark = Column(String, default=None)
    created_time = Column(DateTime, default=datetime.datetime.now, index=True)
    last_updated_time = Column(DateTime, onupdate=datetime.datetime.now)
